﻿using Dm;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace DFGJ.WMS_PDA.WebAPI.Controllers.PDA
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    [AllowAnonymous]
    
    
    public class PDAhuichuanjiekouController : ControllerBase
    {
        private readonly HttpClient _httpClient;
        private readonly IHttpClientFactory _clientFactory;
        public PDAhuichuanjiekouController(IHttpClientFactory clientFactory)
        {
            _clientFactory = clientFactory;
        }

        [HttpGet]
        public async Task<IActionResult> GetChaxunlist()
        {
            var remoteApiUrl = "http://192.168.1.60:1988/api/RFID/GetUserList"; // 替换为远程 API 地址
            var client = _clientFactory.CreateClient();
            var response = await client.GetAsync(remoteApiUrl);

            if (response.IsSuccessStatusCode)
            {
                var responseStream = await response.Content.ReadAsStreamAsync();
                return File(responseStream, "application/json"); // 响应内容为 JSON 格式
            }

            return NotFound();
        }
        [HttpGet]
        public async Task<IActionResult> Get()
        {
            var remoteApiUrl = "http://192.168.1.60:1988/api/RFID/GetUserList"; // 替换为远程 API 地址
            var client = _clientFactory.CreateClient();
            var response = await client.GetAsync(remoteApiUrl);

            if (response.IsSuccessStatusCode)
            {
                var responseStream = await response.Content.ReadAsStreamAsync();
                return File(responseStream, "application/json"); // 响应内容为 JSON 格式
            }

            return NotFound();
        }
    }
}

